Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
이 문제의 핵심은
케이스 분류이다.될 수 있는 경우 중 사전순으로 가장 빠른 경우를 출력해야 하므로 건물의 높이는 낮을수록 좋다.
가장 먼저 가희가 볼 수 있는 건물의 개수(a)와 단비가 볼 수 있는 건물의 개수(b)가 총 건물의 개수(N) + 1 보다 큰 경우는 존재하지 않는다. 따라서 이 경우에는 -1를 출력하면 된다.
가능한 경우에 대해서 보면, 크게 3가지 경우로 나눌 수 있다.
a, b > 1 이면서 a > b인 경우

a, b > 1 이면서 b > a인 경우

a = 1 이면서 b > a인 경우

복기
가능한 최소한의 건물을 두고 나머지 건물을 채워가면 되므로 그리디라고 할 수 있다 ?!